<?php

namespace App\Models;

/**
 * 用户
 * @package App\Models
 */
class User extends BaseModel
{
    const STATUS_KEY = 'US';

    /**
     * 字段
     * @var array
     */
    protected $fillable = [
        'id',
        'role_tag',
        'username',
        'status',
        'name',
        'mobile',
        'desc'
    ];
    /**
     * 状态文本
     * @param $value
     * @return mixed
     */
    public function getStatusTextAttribute($value)
    {
        return \App\Facade\Code::get(self::STATUS_KEY, $this->status);
    }


    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function role()
    {
        return $this->belongsTo(Role::class, 'role_tag','tag');
    }
}
